package com.apartment.own.service.impl;

import java.util.List;
import java.util.Map;

import com.apartment.common.utils.DateUtils;
import com.apartment.own.mapper.CommonMapper;
import com.apartment.own.mapper.OwnResArticleMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.apartment.own.mapper.OwnResArticleInventoryMapper;
import com.apartment.own.domain.OwnResArticleInventory;
import com.apartment.own.service.IOwnResArticleInventoryService;

/**
 * 物品清单Service业务层处理
 * 
 * @author @Dog_E
 * @date 2020-08-28
 */
@Service
public class OwnResArticleInventoryServiceImpl extends ServiceImpl<OwnResArticleInventoryMapper,OwnResArticleInventory> implements IOwnResArticleInventoryService
{
    @Autowired
    private OwnResArticleInventoryMapper ownResArticleInventoryMapper;

    @Autowired
    private CommonMapper commonMapper;

    /**
     * 查询物品清单
     * 
     * @param id 物品清单ID
     * @return 物品清单
     */
    @Override
    public OwnResArticleInventory selectOwnResArticleInventoryById(Long id)
    {
        return ownResArticleInventoryMapper.selectOwnResArticleInventoryById(id);
    }

    /**
     * 查询物品清单列表
     * 
     * @param ownResArticleInventory 物品清单
     * @return 物品清单
     */
    @Override
    public List<OwnResArticleInventory> selectOwnResArticleInventoryList(OwnResArticleInventory ownResArticleInventory)
    {
        return ownResArticleInventoryMapper.selectOwnResArticleInventoryList(ownResArticleInventory);
    }

    /**
     * 新增物品清单
     * 
     * @param ownResArticleInventory 物品清单
     * @return 结果
     */
    @Override
    public int insertOwnResArticleInventory(OwnResArticleInventory ownResArticleInventory)
    {
        ownResArticleInventory.setCreateTime(DateUtils.getNowDate());
        return ownResArticleInventoryMapper.insertOwnResArticleInventory(ownResArticleInventory);
    }

    /**
     * 修改物品清单
     * 
     * @param ownResArticleInventory 物品清单
     * @return 结果
     */
    @Override
    public int updateOwnResArticleInventory(OwnResArticleInventory ownResArticleInventory)
    {
        ownResArticleInventory.setUpdateTime(DateUtils.getNowDate());
        return ownResArticleInventoryMapper.updateOwnResArticleInventory(ownResArticleInventory);
    }

    /**
     * 批量删除物品清单
     * 
     * @param ids 需要删除的物品清单ID
     * @return 结果
     */
    @Override
    public int deleteOwnResArticleInventoryByIds(Long[] ids)
    {
        return ownResArticleInventoryMapper.deleteOwnResArticleInventoryByIds(ids);
    }

    /**
     * 删除物品清单信息
     * 
     * @param id 物品清单ID
     * @return 结果
     */
    @Override
    public int deleteOwnResArticleInventoryById(Long id)
    {
        return ownResArticleInventoryMapper.deleteOwnResArticleInventoryById(id);
    }

    @Override
    public List<Map> inventoryListByHouseId(String id) {
        return commonMapper.listHouseAndInventory(new QueryWrapper<Map>()
                .eq("house.id",id)
        );
    }
}
